<?php
include("../user/userlogincheck.php");
include("../include/config.inc.php");

$a=$_REQUEST["a"];
if($a=='unpay'){
	$consql.="and paystate='0' and userid='$userid' and ordername='订金' order by id DESC";
}elseif($a=='unship'){
	$consql.="and paystate='1' and userid='$userid' and ordername='订金' order by id DESC";
}elseif($a=='unrec'){
	$consql.="and paystate='2' and userid='$userid' and ordername='订金' order by id DESC";
}elseif($a=='unrat'){
	$consql.="and paystate='3' and userid='$userid' and ordername='订金' order by id DESC";
}elseif($a=='Refund'){
	$consql.="and paystate='4' and userid='$userid' and ordername='订金' order by id DESC";
}else{
	$consql.="and userid='$userid' and ordername='订金' order by id DESC";
}
$sql = "select count(*) as count from ".tableprefix."order where 1=1 ".$consql;
$row=$db->fetch_array($db->query($sql));
$count=$row["count"];
$page=new ShowPage;
$page->PageSize=100;
$page->Total=$count;
$page->LinkAry = array("id"=>$id);
$sql="select * from ".tableprefix."order where 1=1 ".$consql." limit ".$page->OffSet();
$result=$db->query($sql);
$showpage= $page->ShowLink();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>我的订单 - 订戏会</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=9,Chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="stylesheet" type="text/css" href="../css/public.css">
<link rel="stylesheet" type="text/css" href="../css/user.css">
</head>

<body>
<section class="orders-list">
<?php     
if($count>0){
?>
<?php
while($row = $db->fetch_array($result)){
$goods_id=$row["goods_id"];
if($row["payment"]=='aliPay'){
$payway="支付宝支付";
}else{
$payway="微信支付";
}
$paystate=$row["paystate"];
if($paystate==-1){
$temp_paystate="已取消";
}elseif($paystate==0){
$temp_paystate="待支付";
}elseif($paystate==1){
$temp_paystate="待卖家确认";
}elseif($paystate==2){
$temp_paystate="待收货";
}elseif($paystate==3){
$temp_paystate="待评价";
}else{
$temp_paystate="已完成";
}
$sql="select * from ".tableprefix."goods where goods_id='$goods_id'";
$res=$db->query($sql);
$ro = $db->fetch_array($res);
?>
	<div class="orders-list-item">
		<div class="orders-store"><a href="../store/index.php?id=<?php echo $ro["store_id"];?>"><span><?php echo $ro["store_name"];?></span></a></div>
		<div class="orders-main">
			<a href="../goods.php?id=<?php echo $goods_id;?>"><img src="../<?php echo $ro["goods_image"];?>"></a>
			<div class="orders-title">
				<a href="../goods.php?id=<?php echo $goods_id;?>"><h3><?php echo $ro["goods_name"];?></h3></a>
				<span>订单编号：<?php echo $row["orderNo"];?><br>订单时间：<?php echo date("Y年m月d日",$row["createtime"])?><br>订单状态：<?php echo $temp_paystate;?></span>
			</div>
			<div class="ordershow"><a href="ordershow.php?orderNo=<?php echo $row["orderNo"];?>">详情</a></div>
		</div>
	</div>
<?php
}
?>
<?php
}else{
echo "<div style='padding:50px 0px;text-align:center;color:#990000;font-size:12px;'>没有找到合乎条件的记录</div>";
}
?>
</section>

<div id="bottom"></div>

<footer id="bar-fixed">
	<a href="../" class="tab-item"><i class="icon-tabbar bar-home"></i>首页</a>
	<a href="../category.php" class="tab-item"><i class="icon-tabbar bar-message"></i>分类</a>
	<a href="../publish/" class="tab-item"><i class="icon-tabbar bar-publish"></i>发起</a>	
	<a href="../user/" class="tab-item active"><i class="icon-tabbar bar-user2"></i>我</a>
</footer>
</body>
</html>
<?php
$db->free_result($result);
$db->close();
exit;
?>